<script setup>
import { useRoute } from "vue-router";
const router = useRoute()
let isDetail = ref(false)

if(router.name == 'resources-id'){
    isDetail = true
}
const props = defineProps({
    documentList: Array
})

let showMobileList = ref(false)
let showKefu = ref(false)
// 滚动到顶部
function scrollToTop() {
    window.scrollTo({
        top: 0,
        behavior: 'smooth', // 平滑滚动
    });
}
const emit = defineEmits(['scrollToComment']);
function scrollToComment(){
    emit("scrollToComment")
}
</script>

<template>
    <div class="rightFix">
        <div class="kefu" @click="showKefu = true">
            <img src="~/assets/kefu/kefu.png" alt="">

        </div>

        <div class="other">
            <el-popover placement="left" trigger="hover" :offset="20" content="18796357645">
                <template #reference>
                    <div class="item">
                        <img src="~/assets/kefu/phone.png" alt="" class="no_active">
                        <img src="~/assets/kefu/phone1.png" alt="" class="active">
                        <span>销售热线</span>
                    </div>
                </template>
            </el-popover>
            <div class="line"></div>
            <template v-if="isDetail">
                <div class="item" @click="scrollToComment()">
                    <img src="~/assets/kefu/comment.png" alt="" class="no_active">
                    <img src="~/assets/kefu/comment1.png" alt="" class="active">
                    <span>评论</span>
                </div>
                <div class="line"></div>
            </template>
            <div class="item" @click="scrollToTop()">
                <img src="~/assets/kefu/top.png" alt="" class="no_active">
                <img src="~/assets/kefu/top1.png" alt="" class="active">
                <span>回到顶部</span>
            </div>
        </div>
    </div>

    <div class="rightFixMobile">
        <div class="box">
            <div class="item" @click="showKefu = true">
                <img src="~/assets/kefu/mobileKefu.png" alt="">
                <div>
                    在线客服
                </div>
            </div>
            <div class="line-box" v-if="documentList && documentList.length != 0">
                <div class="line"></div>
            </div>
            <div class="item" @click="showMobileList = true" v-if="documentList && documentList.length != 0">
                <img src="~/assets/kefu/mobileList.png" alt="">
                <div>
                    文档列表
                </div>
            </div>
        </div>
        <el-drawer v-model="showMobileList" title="文档列表" direction="btt" class="documentList" size="65%">
            <el-collapse model-value="1" accordion>
                <el-collapse-item :title="item.fileName" :name="index" v-for="(item,index) in documentList">
                    <iframe :src="'https://view.xdocin.com/view?src=' + encodeURIComponent(item.url)" frameborder="0" style="width: 100%;height: 40vh;"></iframe>
                </el-collapse-item>
            </el-collapse>
        </el-drawer>
    </div>
    <div class="kefu">
        <el-dialog class="kefuDialog" v-model="showKefu">
            <img src="~/assets/kefu/kefuBg.png" alt="" class="kefuBg">

            <div class="kefu-left">
                <img src="~/assets/kefu/联系我们.png" alt="" class="contact-us">
                <img src="~/assets/kefu.png" alt="" class="qrcode">
<!--                <a href="https://work.weixin.qq.com/kfid/kfcdf95244925f1bcec" target="_blank">-->
<!--                    <div class="wechat">-->
<!--                        <img src="~/assets/kefu/wechat.png" alt="">-->
<!--                        <span>-->
<!--                            手机可直接点击联系客服-->
<!--                        </span>-->
<!--                    </div>-->
<!--                </a>-->

                <!--                <div class="info">-->
                <!--                    这是一段说明文案这是一段说明文案-->
                <!--                </div>-->

            </div>
        </el-dialog>
    </div>
</template>

<style scoped lang="scss">
.rightFix {
    position: fixed;
    right: 100px;
    bottom: 100px;
    display: flex;
    flex-direction: column;
    .kefu {
        cursor: pointer;
        img {
            width: 70px;
        }
    }
    .other {
        margin-top: 24px;
        width: 70px;
        background: #F2F4F7;
        box-shadow: 0px 3px 6px 1px rgba(0, 0, 0, 0.16);
        border-radius: 10px 10px 10px 10px;
        border: 1px solid #FFFFFF;
        padding: 8px;
        box-sizing: border-box;
        .line {
            width: 100%;
            height: 1px;
            background-color: #E0E0E0;
            margin: 10px 0
        }
        .item {
            display: flex;
            flex-direction: column;
            align-items: center;
            cursor: pointer;
            img {
                width: 40px;
                height: 40px;
            }

            .active {
                display: none
            }

            span {
                color: #999999;
                margin-top: 5px;
                font-size: 13px;
            }

            &:hover {
                .no_active {
                    display: none;
                }

                .active {
                    display: block;
                }

                span {
                    color: #4084FA;
                }
            }
        }
    }
}

.rightFixMobile {
    display: none;
}

.kefu {
    :deep(.kefuDialog) {
        padding: 0;
        border-radius: 20px;
        width: 800px;

        .el-dialog__header {
            padding: 0;

            .el-dialog__headerbtn {
                z-index: 2;
            }
        }

        .el-dialog__body {
            position: relative;
            width: 100%;
            height: 421px;
        }

        .kefu-left {
            position: relative;
            left: 50px;
            top: 30px;
            display: flex;
            flex-direction: column;
            align-items: center;
            width: 260px;

            .contact-us {
                width: 100px;
            }

            .qrcode {
                margin-top: 20px;
                max-width: 200px;
            }

            .wechat {
                display: flex;
                align-items: center;
                background: #2E9134;
                border-radius: 10px;
                padding: 4px 8px;
                color: #ffffff;
                font-size: 16px;
                margin-top: 10px;

                img {
                    width: 20px;
                    height: 20px;
                    margin-right: 5px;
                }
            }

            .info {
                font-size: 16px;
                color: #999999;
                margin-top: 10px
            }
        }

        .kefuBg {
            position: absolute;
            top: 0;
            left: 0;
            width: 100%;
            height: 100%;
        }
    }
}

@media screen and (max-width:768px) {
    .rightFix {
        display: none;
    }

    .rightFixMobile {
        display: block;
        position: fixed;
        right: 5px;
        bottom: 40px;

        :deep(.documentList) {
            border-radius: 10px 10px 0 0;
            .el-drawer__header{
                margin-bottom: 10px;
            }
            .el-drawer__body{
                padding: 10px
            }
            .el-collapse{
                border-top: none;
                border-bottom: none;
            }
            .el-collapse-item__header{
                border-bottom: none;
                padding: 0 10px;
                margin-bottom: 5px;
                border-radius: 10px;
                &.is-active{
                    background-color: #F1F2F4;
                    color: #FF8D8D;
                }
            }

        }

        .box {
            width: 40px;
            background: #FFFFFF;
            padding: 5px 0;
            border-radius: 39px;
            border: 1px solid #707070;
            display: flex;
            flex-direction: column;

            .line-box {
                padding: 0 5px;

                .line {
                    background-color: #E3E3E3;
                    height: 1px;
                    width: 100%;
                }
            }

            .item {
                font-size: 8px;
                padding: 8px 0;
                display: flex;
                flex-direction: column;
                align-items: center;
                justify-content: center;
                text-align: center;

                img {
                    width: 24px;
                    height: 24px;
                }
            }
        }
    }

    .kefu {
        :deep(.kefuDialog) {
            width: 90%;

            .el-dialog__body {
                height: 48vw;
            }

            .kefu-left {
                position: relative;
                left: 20px;
                top: 10px;
                display: flex;
                flex-direction: column;
                align-items: center;
                width: 120px;

                .contact-us {
                    width: 50px;
                }

                .qrcode {
                    margin-top: 10px;
                    max-width: 100px;
                }

                .wechat {
                    display: flex;
                    align-items: center;
                    background: #2E9134;
                    border-radius: 10px;
                    padding: 2px 4px;
                    color: #ffffff;
                    font-size: 10px;
                    margin-top: 10px;

                    img {
                        width: 20px;
                        height: 20px;
                        margin-right: 5px;
                    }
                }

                .info {
                    display: none;
                }
            }
        }
    }
}
</style>
